function smoothVideo(videoObj, outputVideoName, hSize, sigma)
    % Smooths the video
    nFrames = videoObj.NumberOfFrames;
    FR = videoObj.FrameRate;
    
    fprintf('\nSmoothing the video...');

    outputVideoObj = VideoWriter(strcat('../Videos/', outputVideoName),'MPEG-4');
    outputVideoObj.FrameRate = FR;

    open(outputVideoObj);

    for i = 1:nFrames
        frame = rgb2gray(read(videoObj, i));

        % Smooths each frame with a Gaussian filter    
        newFrame = smoothFrame(frame, hSize, sigma);

        writeVideo(outputVideoObj, newFrame);
    end
    close(outputVideoObj);

    fprintf('Done!\n');
end

function smoothedFrame = smoothFrame(frame, hSize, sigma)
    % Smooths a frame with a Gaussian filter
    G = fspecial('gaussian', [hSize hSize], sigma);
    smoothedFrame = imfilter(frame, G, 'same');
end